import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:smart_lam/routes/app_pages.dart';
import 'package:smart_lam/style/style.dart';
import 'home_controller.dart';

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GetBuilder<HomeController>(
        builder: (_) {
          return Container(
            height: Get.height,
            decoration: BoxDecoration(
              gradient: RadialGradient(
                center: Alignment(0.4, -0.6),
                radius: 0.6,
                colors: <Color>[
                  Color(0xFF2D2D2D),
                  Color(0xFF1D1D1D),
                  Color(0xFF000000)
                ],
                stops: [0.0, 0.2, 0.8],
              ),
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  alignment: Alignment.center,
                  height: Get.height * 0.5,
                  child: AnimatedBuilder(
                    animation: _.animation,
                    builder: (BuildContext context, Widget? child) {
                      return Transform.scale(
                        scale: _.scaleAnimation.value,
                        child: Transform.translate(
                          offset: _.animation.value,
                          child: child,
                        ),
                      );
                    },
                    child: Image.asset(
                      'assets/image/smart_car.png',
                      width: Get.width,
                    ),
                  ),
                ),
                Container(
                  height: Get.height * 0.5,
                  child: ListTileTheme(
                    dense: true,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        ListTile(
                          leading: Container(
                            height: double.infinity,
                            child: Icon(
                              Icons.ac_unit,
                              color: Colors.white,
                              size: ScreenUtil().setSp(24),
                            ),
                          ),
                          title: Text(
                            '温度',
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 16, color: Colors.white),
                          ),
                          subtitle: Text(
                            '内部-7度',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 14, color: Colors.white),
                          ),
                          trailing: Icon(
                            Icons.keyboard_arrow_right,
                            color: Colors.white,
                            size: ScreenUtil().setSp(24),
                          ),
                        ),
                        ListTile(
                          leading: Container(
                            height: double.infinity,
                            child: Icon(
                              Icons.cloud_download_outlined,
                              color: Colors.white,
                              size: ScreenUtil().setSp(24),
                            ),
                          ),
                          title: Text(
                            '软件更新',
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 16, color: Colors.white),
                          ),
                          subtitle: Text(
                            '已是最新版本',
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 14, color: Colors.white),
                          ),
                          trailing: Icon(
                            Icons.keyboard_arrow_right,
                            color: Colors.white,
                            size: ScreenUtil().setSp(24),
                          ),
                          onTap: () {
                            Get.toNamed<void>(Routes.lamp);
                          },
                        ),
                        ListTile(
                          leading: Container(
                            height: double.infinity,
                            child: Icon(
                              Icons.brightness_5,
                              color: Colors.white,
                              size: ScreenUtil().setSp(24),
                            ),
                          ),
                          title: Text(
                            '氛围灯',
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 16, color: Colors.white),
                          ),
                          subtitle: Text(
                            '是否已连接',
                            style: CustomStyle(context).customTextStyle(
                                fontSize: 14, color: Colors.white),
                          ),
                          trailing: Icon(
                            Icons.keyboard_arrow_right,
                            color: Colors.white,
                            size: ScreenUtil().setSp(24),
                          ),
                          onTap: () {
                            Get.toNamed<void>(Routes.bleDevices);
                          },
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          );
        },
      ),
    );
  }
}
